import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'
import VueAxios from 'vue-axios'
import Vant from 'vant'
import store from './store'

import 'vant/lib/index.css';
import 'amfe-flexible/index.js'
import './assets/icon/music-icon/iconfont.css'

import $ from 'jquery' //导入jquery

import HappyScroll from 'vue-happy-scroll'
// 引入css
import 'vue-happy-scroll/docs/happy-scroll.css'
Vue.use(HappyScroll)


Vue.config.productionTip = false
Vue.use(VueAxios, axios)
Vue.use(Vant);

// import { Calendar } from 'vant';
// Vue.use(Calendar);

// 实现路由拦截，需要登录才能进入
router.beforeEach((to,from,next)=>{
  // 判断该路由是否需要登录权限
  if(to.meta.requireAuth) {
    if(sessionStorage.getItem('id')) {
      next()
    } else {
      next({
        path:"/login/login",
        query:{redirect:"需要登录"}
      })
    }
  } else {
    next()
  }
})


// 默认首页
router.push('/login/login')

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
